<!DOCTYPE html>
<html
        xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout" xmlns:th="http://www.thymeleaf.org"
        layout:decorate="~{base/layout}">


<div layout:fragment="content">
    <div class="med_tittle_section">
        <div class="med_img_overlay"></div>
        <div class="container">
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="med_tittle_cont_wrapper">
                        <div class="med_tittle_cont">
                            <ol class="breadcrumb">
                                <li><a th:href="@{/}">系统首页</a></li>
                                <li><a th:href="@{/strategy/pushStrategyListUI}">我发布的攻略</a></li>
                            </ol>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="page-container">

        <div class="container">
            <div class="row med_toppadder50 med_bottompadder50">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <h1>我发布的攻略</h1>
                    <div style="min-height: 150px" class="cy-news-grid-item" th:each="travelStrategy:${page.content}">
                        <div class="cy-ib-thumbnail pull-left">
                        </div>
                        <div class="booklet-cont">
                            <h5><a th:href="@{/strategy/travelStrategyDetailsUI(id=${travelStrategy.id})}"
                                   th:text="'攻略标题: ' + ${travelStrategy.title}"></a></h5>
                            <div class="cy-summary-intro">
                                <p th:text="${travelStrategy.describe}">
                                </p>
                                <div align="right" style="float:right" th:if="${travelStrategy.status == 2}">
                                    <button type="button" th:onclick="aaa([[${travelStrategy.errorMessage}]])"
                                            class="btn btn-default btn-danger">审核不通过,查看原因
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div align="right" style="float:right">
                        <button type="button" onclick="reset()" class="btn btn-default btn-warning">发布攻略</button>
                    </div>
                    <!--弹框-->
                    <div class="modal fade" id="exampleModal">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
                                            aria-hidden="true">&times;</span></button>
                                    <h4 class="modal-title" id="exampleModalLabel"></h4>
                                </div>
                                <div class="modal-body">
                                    <form method="post" name="insertMember"
                                          id="insertMember" class="form-horizontal">
                                        <!--隐藏的-->
                                        <input type="text" id="id" name="id" hidden>

                                        <div id="usernameDiv" class="form-group m-b-10" style="text-align:right">
                                            <label class="col-sm-4 control-label">
                                                <label style="color: red">*</label>攻略标题:
                                            </label>
                                            <div class="col-sm-7">
                                                <input type="text" class="form-control" id="title" name="title">
                                            </div>
                                        </div>
                                        <div class="form-group m-b-10" style="text-align:right">
                                            <label class="col-sm-4 control-label">
                                                攻略描述:
                                            </label>
                                            <div class="col-sm-7">
                                <textarea type="text" rows="7" cols="20" class="form-control" id="describe"
                                          name="describe">
                                </textarea>
                                            </div>
                                        </div>

                                    </form>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-default" data-dismiss="modal">返回</button>
                                    <button type="button" class="btn btn-info" onclick="saveForm()">提交</button>
                                </div>
                            </div>
                        </div>
                    </div>

                </div>
            </div>
        </div>
    </div>
    <script th:src="@{/js/jquery_min.js}"></script>
    <script th:src="@{/js/bootstrap.min.js}"></script>
    <script th:src="@{/js/wow.min.js}"></script>
    <script th:src="@{/js/custom.js}"></script>
    <script th:src="@{/plugins/slider-pro/js/jquery.sliderPro.min.js}"></script>
    <script th:src="@{/plugins/owlcarousel/js/owl.carousel.min.js}"></script>
    <script th:src="@{/layer/layer.js}"></script>
    <script th:inline="javascript">


        function cancelTravelStrategyReserve(id) {
            $.ajax({
                url: '/travel/strategy/cancelTravelStrategyReserve',
                data: {"id": id},
                type: 'post',
                dataType: 'json',
                success: function (result) {
                    if (result.code === 200) {
                        window.location.reload();
                    } else {
                        layer.open({
                            title: '错误提示',
                            content: result.message
                        });
                    }
                }
            })
        }

        function aaa(message) {
            alert(message);
        }

        function reset() {
            //全部清空
            $('#exampleModalLabel').text('发布攻略');
            //id
            $('#id').val('');
            //name
            $('#title').val('');
            //describe
            $('#describe').val('');
            //显示模态框
            $('#exampleModal').modal('show')

        }

        $('.filter-type-box span a').click(function () {
            if ($(this).hasClass('active'))
                $(this).removeClass('active')
            else
                $(this).addClass('active')
        });
        $('.cy-summary-intro p').each(function () {
            var maxwidth = 260;
            var backup = $(this).html();
            var height_lg = $(this).parent().height();
            if ($(this).text().length > maxwidth) {
                $(this).text($(this).text().substring(0, maxwidth));
                $(this).html($(this).html() + '...');
                var backup_1 = $(this).html();
                var height_sm = $(this).parent().height();
                $(this).parent().css('height', height_sm);
            }
            var d_value = height_lg - height_sm;
            // $(this).next().click(function () {
            //     if ($(this).html() == '更多') {
            //         $(this).html('收起');
            //         $(this).prev().html(backup);
            //         $(this).parent().animate({height: '+=' + d_value + 'px'});
            //     } else {
            //         $(this).html('更多');
            //         $(this).prev().html(backup_1);
            //         $(this).parent().animate({height: '-=' + d_value + 'px'});
            //     }
            // })
        });

        function saveForm() {
            //name
            var title = $('#title').val();


            if ($.trim(title) === '') {
                layer.msg("标题不能为空");
                return;
            }
            $.ajax({
                url: '/travel/strategy/saveTravelStrategy',
                data: $("#insertMember").serialize(),
                type: 'post',
                dataType: 'json',
                success: function (result) {
                    if (result.code === 200) {
                        window.location.href = "/travel/strategy/pushStrategyListUI";
                    } else {
                        layer.open({
                            title: '错误提示',
                            content: result.message
                        });
                    }
                }
            })
        }
    </script>
</div>
</html>
